package com.qidianit.mes.device.service.impl;

import com.github.pagehelper.PageHelper;
import com.qidianit.common.pojo.MESResult;
import com.qidianit.common.util.Constant;
import com.qidianit.mes.device.mapper.DeviceLedgerMapper;
import com.qidianit.mes.device.service.DeviceLedgerService;
import com.qidianit.mes.pojo.DeviceLedger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeviceLedgerServiceImpl implements DeviceLedgerService {

    @Autowired
    DeviceLedgerMapper deviceLedgerMapper;
    @Override
    public MESResult list(String deviceCode, String deviceName, Integer Page, Integer Limit) {
        PageHelper.startPage(Page,Limit);
         List<DeviceLedger> deviceLedgerList =deviceLedgerMapper.list(deviceCode,deviceName);
        return MESResult.success(deviceLedgerList);
    }

    @Override
    public MESResult add(DeviceLedger deviceLedger) {
        deviceLedger.setDeviceStatus("1");
        deviceLedgerMapper.add(deviceLedger);
        return MESResult.success(Constant.RESPONSE_STATUS_OK);
    }

    @Override
    public MESResult edit(DeviceLedger deviceLedger) {
        deviceLedgerMapper.edit(deviceLedger);
        return MESResult.success(Constant.RESPONSE_STATUS_OK);
    }

    @Override
    public MESResult delete(String id) {
        deviceLedgerMapper.delete(id);
        return MESResult.success(Constant.RESPONSE_STATUS_OK);
    }
}
